/*
 *  The MIT License
 * 
 *  Copyright 2011 Edwin Bratini <edwin.bratini@gmail.com>.
 * 
 *  Permission is hereby granted, free of charge, to any person obtaining a copy
 *  of this software and associated documentation files (the "Software"), to deal
 *  in the Software without restriction, including without limitation the rights
 *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 *  copies of the Software, and to permit persons to whom the Software is
 *  furnished to do so, subject to the following conditions:
 * 
 *  The above copyright notice and this permission notice shall be included in
 *  all copies or substantial portions of the Software.
 * 
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 *  THE SOFTWARE.
 */

/*
 * BaseConsulta.java
 *
 * Created on May 5, 2011, 12:01:30 AM
 */
package com.prebea.syscafil.ui;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;

/**
 *
 * @author Edwin Bratini <edwin.bratini@gmail.com>
 */
public class BaseConsulta extends javax.swing.JPanel {

    /** Creates new form BaseConsulta */
    public BaseConsulta() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        bgrOpBusqueda = new javax.swing.ButtonGroup();
        lblResultados = new javax.swing.JLabel();
        scrResultados = new javax.swing.JScrollPane();
        jtbResultados = new javax.swing.JTable();
        pnlConsultaHeader = new javax.swing.JPanel();
        pnlOpBusqueda = new javax.swing.JPanel();
        rdbField1 = new javax.swing.JRadioButton();
        rdbField2 = new javax.swing.JRadioButton();
        rdbField3 = new javax.swing.JRadioButton();
        chkFiltro = new javax.swing.JCheckBox();
        txtBusqueda = new javax.swing.JTextField();
        btnBuscar = new javax.swing.JButton();
        pnlBotonesEdicion = new javax.swing.JPanel();
        btnDetalles = new javax.swing.JButton();
        btnEditar = new javax.swing.JButton();
        btnBorrar = new javax.swing.JButton();

        lblResultados.setText("Resultados");

        scrResultados.setName("scrResultados"); // NOI18N

        jtbResultados.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jtbResultados.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        scrResultados.setViewportView(jtbResultados);

        pnlConsultaHeader.setBorder(javax.swing.BorderFactory.createEtchedBorder(java.awt.Color.white, java.awt.Color.lightGray));

        pnlOpBusqueda.setBorder(javax.swing.BorderFactory.createTitledBorder("Opciones de Busqueda"));
        pnlOpBusqueda.setName("pnlOpBusqueda"); // NOI18N

        bgrOpBusqueda.add(rdbField1);
        rdbField1.setSelected(true);
        rdbField1.setText("Field 1");
        rdbField1.setName("rdbField1"); // NOI18N

        bgrOpBusqueda.add(rdbField2);
        rdbField2.setText("Field 2");
        rdbField2.setName("rdbField2"); // NOI18N

        bgrOpBusqueda.add(rdbField3);
        rdbField3.setText("Field 3");
        rdbField3.setName("rdbField3"); // NOI18N

        chkFiltro.setText("Filtro");
        chkFiltro.setName("chkFiltro"); // NOI18N
        chkFiltro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkFiltroActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlOpBusquedaLayout = new javax.swing.GroupLayout(pnlOpBusqueda);
        pnlOpBusqueda.setLayout(pnlOpBusquedaLayout);
        pnlOpBusquedaLayout.setHorizontalGroup(
            pnlOpBusquedaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlOpBusquedaLayout.createSequentialGroup()
                .addComponent(rdbField1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(rdbField2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(rdbField3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(27, 27, 27))
            .addGroup(pnlOpBusquedaLayout.createSequentialGroup()
                .addComponent(chkFiltro)
                .addContainerGap())
        );
        pnlOpBusquedaLayout.setVerticalGroup(
            pnlOpBusquedaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlOpBusquedaLayout.createSequentialGroup()
                .addComponent(chkFiltro)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(pnlOpBusquedaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rdbField1)
                    .addComponent(rdbField2)
                    .addComponent(rdbField3))
                .addContainerGap())
        );

        txtBusqueda.setName("txtBusqueda"); // NOI18N
        txtBusqueda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtBusquedaActionPerformed(evt);
            }
        });

        btnBuscar.setText("Buscar");
        btnBuscar.setName("btnBuscar"); // NOI18N

        javax.swing.GroupLayout pnlConsultaHeaderLayout = new javax.swing.GroupLayout(pnlConsultaHeader);
        pnlConsultaHeader.setLayout(pnlConsultaHeaderLayout);
        pnlConsultaHeaderLayout.setHorizontalGroup(
            pnlConsultaHeaderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlConsultaHeaderLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pnlOpBusqueda, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(txtBusqueda, javax.swing.GroupLayout.DEFAULT_SIZE, 569, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnBuscar)
                .addContainerGap())
        );
        pnlConsultaHeaderLayout.setVerticalGroup(
            pnlConsultaHeaderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlConsultaHeaderLayout.createSequentialGroup()
                .addContainerGap(65, Short.MAX_VALUE)
                .addGroup(pnlConsultaHeaderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtBusqueda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnBuscar))
                .addGap(17, 17, 17))
            .addGroup(pnlConsultaHeaderLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pnlOpBusqueda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(14, Short.MAX_VALUE))
        );

        pnlBotonesEdicion.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                pnlBotonesEdicionComponentShown(evt);
            }
        });

        btnDetalles.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/imagenes/detalles.png"))); // NOI18N
        btnDetalles.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDetallesActionPerformed(evt);
            }
        });

        btnEditar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/imagenes/editar.png"))); // NOI18N

        btnBorrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/imagenes/Borrar.png"))); // NOI18N

        javax.swing.GroupLayout pnlBotonesEdicionLayout = new javax.swing.GroupLayout(pnlBotonesEdicion);
        pnlBotonesEdicion.setLayout(pnlBotonesEdicionLayout);
        pnlBotonesEdicionLayout.setHorizontalGroup(
            pnlBotonesEdicionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlBotonesEdicionLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btnDetalles, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnEditar, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnBorrar, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        pnlBotonesEdicionLayout.setVerticalGroup(
            pnlBotonesEdicionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlBotonesEdicionLayout.createSequentialGroup()
                .addGroup(pnlBotonesEdicionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnBorrar, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnDetalles, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnEditar, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(scrResultados, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 886, Short.MAX_VALUE)
                    .addComponent(pnlConsultaHeader, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(lblResultados)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 745, Short.MAX_VALUE)
                        .addComponent(pnlBotonesEdicion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pnlConsultaHeader, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lblResultados)
                    .addComponent(pnlBotonesEdicion, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(scrResultados, javax.swing.GroupLayout.DEFAULT_SIZE, 350, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void chkFiltroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkFiltroActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_chkFiltroActionPerformed

    private void btnDetallesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDetallesActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btnDetallesActionPerformed

    private void pnlBotonesEdicionComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_pnlBotonesEdicionComponentShown
        // TODO add your handling code here:
        pnlBotonesEdicion.setVisible(false);
    }//GEN-LAST:event_pnlBotonesEdicionComponentShown

    private void txtBusquedaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtBusquedaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtBusquedaActionPerformed

    public ButtonGroup getBgrOpBusqueda() {
        return bgrOpBusqueda;
    }

    public JButton getBtnBuscar() {
        return btnBuscar;
    }

    public JCheckBox getChkFiltro() {
        return chkFiltro;
    }

    public JTable getJtbResultados() {
        return jtbResultados;
    }

    public JLabel getLblResultados() {
        return lblResultados;
    }

    public JPanel getPnlConsultaHeader() {
        return pnlConsultaHeader;
    }

    public JPanel getPnlOpBusqueda() {
        return pnlOpBusqueda;
    }

    public JRadioButton getRdbField1() {
        return rdbField1;
    }

    public JRadioButton getRdbField2() {
        return rdbField2;
    }

    public JRadioButton getRdbField3() {
        return rdbField3;
    }

    public JScrollPane getScrResultados() {
        return scrResultados;
    }

    public JTextField getTxtBusqueda() {
        return txtBusqueda;
    }

    public JButton getBtnBorrar() {
        return btnEditar;
    }

    public JButton getBtnEditar() {
        return btnDetalles;
    }

    public JButton getBtnVerDetalles() {
        return btnBorrar;
    }

    public JPanel getPnlBotonesEdicion() {
        return pnlBotonesEdicion;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup bgrOpBusqueda;
    private javax.swing.JButton btnBorrar;
    private javax.swing.JButton btnBuscar;
    private javax.swing.JButton btnDetalles;
    private javax.swing.JButton btnEditar;
    private javax.swing.JCheckBox chkFiltro;
    private javax.swing.JTable jtbResultados;
    private javax.swing.JLabel lblResultados;
    private javax.swing.JPanel pnlBotonesEdicion;
    private javax.swing.JPanel pnlConsultaHeader;
    private javax.swing.JPanel pnlOpBusqueda;
    private javax.swing.JRadioButton rdbField1;
    private javax.swing.JRadioButton rdbField2;
    private javax.swing.JRadioButton rdbField3;
    private javax.swing.JScrollPane scrResultados;
    private javax.swing.JTextField txtBusqueda;
    // End of variables declaration//GEN-END:variables
}
